import { Controller, Get, Post, Body, Patch, Param, Delete,Req } from '@nestjs/common';
import { ArticleService } from './article.service';
import { CreateArticleDto,getArticleListDto,getArticleDetailDto } from './dto/create-article.dto';

import { UpdateArticleDto } from './dto/update-article.dto';

@Controller('article')
export class ArticleController {
  constructor(private readonly articleService: ArticleService) {}

  @Post('like')
  like(@Body() articleid) {
    return this.articleService.like(articleid);
  }
  @Post('add')
  create(@Body() createArticleDto: CreateArticleDto) {
    return this.articleService.create(createArticleDto);
  }

  @Post('findAll')
  findAll(@Body() query: getArticleListDto, @Req() req) {
    return this.articleService.findAll(query, req);
  }
  @Post('findAllbyuser')
  findAllbyuser(@Body() userid: string, @Req() req) {
    return this.articleService.findAllbyuser(userid, req);
  }
  @Post('findOne')
  findOne(@Body() articleid) {
    return this.articleService.findOne(articleid);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateArticleDto: UpdateArticleDto) {
    return this.articleService.update(+id, updateArticleDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.articleService.remove(+id);
  }
}
